package com.py.credit.controller;

import com.alibaba.fastjson.JSONObject;
import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.XydUploadService;
import com.py.framework.core.annotation.IgnoreAuthority;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import xyrCredit.XyrDataInterfaceService;

import java.io.UnsupportedEncodingException;
import java.math.BigInteger;

@RestController
@RequestMapping("/xydupload")
public class XydUploadController {
    private final Logger log = LoggerFactory.getLogger(XydUploadController.class);
    protected int socketTimeout = 30000;
    protected int connectTimeout = 30000;

    protected String apiKey = "72C136A8A67D4FC2A82797FE1952C5B9";
    protected String wsaddr = "http://59.227.152.250:8080/xyd/ws/XyrDataInterfaceService?wsdl";
    protected String privateKey = "26E0A4E80F19C59D1EC364F4A5A66B0EF91786977835A619C29B233771BA30B7";

    @Autowired
    private XydUploadService xydUploadService;


    @IgnoreAuthority
    @RequestMapping({"/xydupload.json"})
    public RestServiceResult setEnterprises(int type) {
        RestServiceResult result = new RestServiceResult();

        try {
            String e = xydUploadService.setEnterprises(apiKey,privateKey,wsaddr,type);
            result.setData(e);
            return result;
        } catch (Exception var4) {
            ExceptionLogger.error("XydUploadController#xydupload", "数据上报异常" + var4.getMessage(), var4);
            result.setCode(RestServiceResult.CODE_UNKNOW);
            result.setMsg("数据上报异常");
            return result;
        }
    }

}
